package fun.qu_an.minecraft.mini_games_helper.client.mixin;

import fun.qu_an.minecraft.mini_games_helper.client.config.MiniGamesHelperClientConfig;
import fun.qu_an.minecraft.mini_games_helper.client.handle.ForceOptionHelperSodium;
import fun.qu_an.minecraft.mini_games_helper.client.handle.ForceOptionHelperVanilla;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.network.packet.s2c.play.EnterReconfigurationS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayNetworkHandler.class)
public class ClientPlayNetworkHandlerMixin {
	@Inject(method = "onEnterReconfiguration(Lnet/minecraft/network/packet/s2c/play/EnterReconfigurationS2CPacket;)V",
		at = @At("HEAD"))
	private void beforeOnEnterReconfiguration(EnterReconfigurationS2CPacket packet, CallbackInfo ci) {
		MinecraftClient client = MinecraftClient.getInstance();
		client.execute(() -> {
			System.out.println("revoking shader...");
			MiniGamesHelperClientConfig.reset();
			ForceOptionHelperVanilla.revoke();
			ForceOptionHelperSodium.revoke();
		});
	}
}
